using UnityEngine;
using UnityEngine.UI;
using QFramework;
using DG.Tweening;

namespace HareGame
{
    public class UIFiveStarData : UIPanelData
    {
    }
    public partial class UIFiveStar : UIBase
    {

        protected override void OnInit(IUIData uiData = null)
        {
            base.OnInit();
            mData = uiData as UIFiveStarData ?? new UIFiveStarData();
        }

        protected override void OnOpen(IUIData uiData = null)
        {
            base.OnOpen();

            GameEntry.Util.DoScaleWithMask(Mask, Bg);

            btnClose.onClick.AddListener(OnCloseClick);
            btnNo.onClick.AddListener(OnCloseClick);
            btnYes.onClick.AddListener(OnYesClick);
        }

        protected override void OnClose()
        {
            base.OnClose();

            btnClose.onClick.RemoveListener(OnCloseClick);
            btnNo.onClick.RemoveListener(OnCloseClick);
            btnYes.onClick.RemoveListener(OnYesClick);
        }

        void OnYesClick()
        {
            GameEntry.SDK.Go2Store();
            GameEntry.UI.CloseUI(this);
        }

        void OnCloseClick()
        {
            if (!m_HandleAble)
                return;

            m_HandleAble = false;
            GameEntry.Util.DoHideWithMask(Mask, Bg).OnComplete(() =>
            {
                GameEntry.UI.CloseUI(this);
            });
        }
    }
}
